var express = require('express');
const {createReadStream, statSync} = require("node:fs");
var router = express.Router();

/* GET users listing. */
router.post('/', function (req, res, next) {
    const stat = statSync('./assets/cart.xlsx');
    const fileSize = stat.size;
    const fileName = 'cart.xlsx'; // 你想要的文件名

    res.setHeader('Content-Disposition', 'attachment; filename=' + fileName);
    res.setHeader('Content-Type', 'application/octet-stream');
    res.setHeader('Content-Length', fileSize);

    const readStream = createReadStream('./assets/cart.xlsx');
    readStream.pipe(res);
});

module.exports = router;
